import requests
import json
web_url = "http://127.0.0.1/api/"
tsessionid = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuaWNrbmFtZSI6ImtrIiwiaWQiOjMsImV4cCI6MTU1MjUzNjQxNn0.6DdEaLKV0G-9C7vJQiaf-qYsHfFnkP5krH_OtMqIFos"

headers = {
    'tsessionid': tsessionid
}
def test_add_post():
    data = {
        'title': "test",
        'content':"asdf"
    }
    requests.post("{}/groups/{}/posts/".format(web_url,1),headers=headers,json=data)

def get_group_detail():
    data = requests.get("{}/groups/{}/".format(web_url,1),headers=headers)
    print(data.text)

def get_post(post_id):
    data = requests.get("{}/posts/{}/".format(web_url, post_id),headers=headers)
    print(data.text)

def add_comments(post_id):
    data = requests.post("{}/posts/{}/comments/".format(web_url, post_id), headers=headers,json={"content":"ceshi"})
    print(data.text)

def get_comments(post_id):
    data = requests.get("{}/posts/{}/comments/".format(web_url, post_id), headers=headers)
    print(data.text)

def add_reply(comment_id, replyed_user):
    data = requests.post("{}/comments/{}/replys/".format(web_url, comment_id), headers=headers, json={"content": "ceshi","replyed_user":replyed_user})
    print(data.text)

def get_reply(comment_id):
    data = requests.get("{}/comments/{}/replys/".format(web_url, comment_id), headers=headers)
    print(data.text)

def add_like(comment_id):
    data = requests.post("{}/comments/{}/likes/".format(web_url, comment_id), headers=headers)
    print(data.text)

if __name__ == '__main__':
    #test_add_post()
    #get_group_detail()
    #get_post(4)
    #add_comments(1)
    #get_comments(1)
    #add_reply(1, 3)
    #get_reply(1)
    add_like(1)
